/// 矩形两边黑色渐变阴影；形成两边折弯的立体感；
/// @param $size: 30px; 形成的阴影总宽度
/// @param $bg_color: #88c425; 背景颜色；默认绿色
/// @param $fadeOut: 0.6; 渐变透明度；默认0.6
@function bothSideShadow($size: 30px, $bg_color: #88c425, $fadeOut: 0.6) {
  @return linear-gradient(
      90deg,
      fade-out(black, $fadeOut),
      transparent calc($size / 2) calc(100% - $size / 2),
      fade-out(black, $fadeOut)
    )
    $bg_color;
}

/// 多边形裁剪
@function polygon_clip($points: 10, $startPoint: 0) {
  @if $points < 3 {
    @error "points must be greater than 2";
  }
  $angle: calc(360deg / $points);
  $coords: "";
  @for $point from $startPoint through ($points + $startPoint - 1) {
    $pointAngle: $angle * $point;
    $x: 50% + percentage(calc(sin($pointAngle) / 2));
    $y: 50% - percentage(calc(cos($pointAngle) / 2));
    $coords: $coords + $x + " " + $y;
    @if $point !=$points + $startPoint - 1 {
      $coords: $coords + ",";
    }
    $point: $point + 1;
  }
  $polygon: "polygon(" + $coords + ")";
  @return unquote($polygon);
}

/// 标签作为关联的镜像
$selector-map: (
  "main": ".main-nav",
  "aside": ".sidebar",
  "login": ".user-account-area",
);

/// 根据传入的键值，返回对应的类名
@function selector($selector-keys...) {
  $selector-list: ();
  @each $key, $value in $selector-keys {
    $selector-value: map-get($selector-map, $key);
    $selector-list: append(
      $selector-list,
      unquote($selector-value or $key),
      comma
    );
  }
  @return $selector-list;
}

/// 选择器混合
@mixin selector($selector-keys...) {
  #{selector($selector-keys...)} {
    @content;
  }
}
